package jeej;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

public class Overview extends JPanel
{	
	private LovePanel lovePanel;
	private JMenuBar menuBar;
	private JMenu menu1;
	private JFrame byme;
	private JLabel naam;
	private EventHandler event;
	private JMenuItem exit, by;
	private JLabel label;
	
	public Overview()
	{
		Font font = new Font("arial", Font.PLAIN, 12);
		setFont(font);
		
		lovePanel = new LovePanel();
		menuBar = new JMenuBar();
		menu1 = new JMenu("I luff you");
		label = new JLabel("I luff you schatje van me :$");
		
		event = new EventHandler();
		exit = new JMenuItem("Exit");
		exit.addActionListener(event);
		by = new JMenuItem("by me :$");
		by.addActionListener(event);
		popup();
		
		menu1.add(by);
		menu1.add(exit);
		menuBar.add(menu1);
		
		setLayout(new BorderLayout());
		add(menuBar, BorderLayout.NORTH);
		add(lovePanel, BorderLayout.CENTER);
		add(label, BorderLayout.SOUTH);
	}
	
	public void popup()
	{
		naam = new JLabel("van mij voor jouw lieverd :$");
		byme = new JFrame();
		byme.setVisible(false);
		byme.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		byme.setBounds(300, 200, 200, 100);
		byme.setResizable(false);
		byme.setLayout(new GridLayout(4, 1));
		byme.add(naam);
	}
	
	class EventHandler implements ActionListener
	{

		@Override
		public void actionPerformed(ActionEvent e)
		{
			if(e.getSource() == exit)
			{
				System.exit(1);
			}
			if(e.getSource() == by)
			{
				byme.setVisible(true);
			}
		}
	}
}
